<?php 
function countMoney($income, $expence, $line) 
{
    if ((int) $line[2] > 0)
    {            
        $income += (int) $line[2];
    } else {
        $expence += (int) $line[2];
    }
}

function parseCsv($content, $income, $expence) 
{
    while (($line = fgetcsv($content)) !== false) 
    { 
        countMoney($income, $expence, $line);
        ?>
        <div class="row">
            <p><?= $line[0] ?></p>
            <p><?= $line[1] ?></p>
            <p><?= $line[2] ?>$</p>
        </div> 
        <?php
    }
}    

function calculateNetTotal($income, $expence)
{
    if ($expence < 0) 
    {
        return $income + $expence;
    }            
    else
    {
        return $income;
    }            
}